/*
 * 类名称:BusinessPlaceController.java
 * 包名称:com.lht.admin.controller
 *
 * 修改履历:
 *     日期                       修正者        主要内容
 *     2020-01-02 01:09:47        ZhengZhanWu     初版做成
 */
package com.lht.admin.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lht.admin.annotation.SysLog;
import com.lht.admin.utils.R;
import com.lht.admin.controller.AbstractController;
import com.lht.admin.entity.BusinessPlaceEntity;
import com.lht.admin.service.BusinessPlaceService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 经营场所管理表Controller
 *
 * @author ZhengZhanWu
 * @date 2020-01-02 01:09:47
 */
@RestController
@RequestMapping("/businessplace")
public class BusinessPlaceController extends AbstractController {
    @Autowired
    private BusinessPlaceService businessPlaceService;

    /**
     * 查看所有列表
     *
     * @param params 查询参数
     * @return R
     */
    @RequestMapping("/queryAll")
    @RequiresPermissions("businessplace:list")
    public R queryAll(@RequestParam Map<String, Object> params) {
        List<BusinessPlaceEntity> list = businessPlaceService.queryAll(params);

        return R.ok().put("list", list);
    }

    /**
     * 分页查询经营场所管理表
     *
     * @param params 查询参数
     * @return R
     */
    @GetMapping("/list")
    @RequiresPermissions("businessplace:list")
    public R list(@RequestParam Map<String, Object> params) {
        Page page = businessPlaceService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 根据主键查询详情
     *
     * @param id 主键
     * @return R
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("businessplace:info")
    public R info(@PathVariable("id") Long id) {
        BusinessPlaceEntity businessPlace = businessPlaceService.getById(id);

        return R.ok().put("businessplace", businessPlace);
    }

    /**
     * 新增经营场所管理表
     *
     * @param businessPlace businessPlace
     * @return R
     */
    @SysLog("新增经营场所管理表")
    @RequestMapping("/save")
    @RequiresPermissions("businessplace:save")
    public R save(@RequestBody BusinessPlaceEntity businessPlace) {

        businessPlaceService.add(businessPlace);

        return R.ok();
    }

    /**
     * 修改经营场所管理表
     *
     * @param businessPlace businessPlace
     * @return R
     */
    @SysLog("修改经营场所管理表")
    @RequestMapping("/update")
    @RequiresPermissions("businessplace:update")
    public R update(@RequestBody BusinessPlaceEntity businessPlace) {

        businessPlaceService.update(businessPlace);

        return R.ok();
    }

    /**
     * 根据主键删除经营场所管理表
     *
     * @param ids ids
     * @return R
     */
    @SysLog("删除经营场所管理表")
    @RequestMapping("/delete")
    @RequiresPermissions("businessplace:delete")
    public R delete(@RequestBody Long[] ids) {
        businessPlaceService.deleteBatch(ids);

        return R.ok();
    }
}
